package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.IotProductService;
import com.econ.powercloud.ems.dal.mapper.IotProductServiceMapper;
import org.springframework.stereotype.Repository;

/**
 * @ Description:产品服务DAO
 */
@Repository
public class IotProductServiceDAO extends ServiceImpl<IotProductServiceMapper, IotProductService> {

    public IotProductService selectByProductKeyAndType(String productKey, Integer type) {
        LambdaQueryWrapper<IotProductService> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(IotProductService::getProductKey,productKey);
        wrapper.eq(type!=null,IotProductService::getType,type);
        wrapper.last("limit 1");
        return this.baseMapper.selectOne(wrapper);
    }
}
